package com.mnsq.common.bean.vo.book;

import com.mnsq.common.bean.annotation.JpaFields;
import com.mnsq.common.bean.condition.CommonBaseCondition;
import com.mnsq.common.bean.entity.book.Book;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

/**
 * @author Administrator
 * @date 2019/1/22 0022
 */
@Data
@Accessors(chain = true)
public class BookCondition extends CommonBaseCondition<Book> {
    @ApiModelProperty("书名，模糊查询")
    private String name;
    @ApiModelProperty("作者，模糊查询")
    private String author;
    @ApiModelProperty("年份，模糊查询")
    @JpaFields(attrType = JpaFields.AttrType.EQ)
    private String year;
    @ApiModelProperty("分值，模糊查询")
    @JpaFields(attrType = JpaFields.AttrType.EQ)
    private String score;
    @ApiModelProperty("类型id")
    @JpaFields(attrType = JpaFields.AttrType.EQ, ignore = true)
    private String cateId;
    @ApiModelProperty("评论内容")
    @JpaFields(attrType = JpaFields.AttrType.EQ, ignore = true)
    private String comment;
    @ApiModelProperty("用户id")
    @JpaFields(attrType = JpaFields.AttrType.EQ, ignore = true)
    private Long userId;
    @ApiModelProperty("书籍id")
    @JpaFields(attrType = JpaFields.AttrType.EQ, ignore = true)
    private Long bookId;
    @ApiModelProperty("书籍详细信息id")
    @JpaFields(attrType = JpaFields.AttrType.EQ, ignore = true)
    private Long bookInfoId;

    @ApiModelProperty(hidden = true)
    @Override
    public Book getInstance() {
        return new Book();
    }

    @Override
    public boolean isEmpty() {
        if (StringUtils.isNotBlank(name)) {
            return false;
        } else if (StringUtils.isNotBlank(author)) {
            return false;
        } else if (StringUtils.isNotBlank(year)) {
            return false;
        } else if (StringUtils.isNotBlank(score)) {
            return false;
        }
        return true;
    }
}
